package com.campus.activity.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.campus.activity.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户Mapper接口
 * 
 * @author System
 * @since 2024
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据用户名查询用户
     * 
     * @param username 用户名
     * @return 用户信息
     */
    @Select("SELECT * FROM user WHERE username = #{username} AND deleted = 0")
    User selectByUsername(@Param("username") String username);

    /**
     * 根据用户角色查询用户列表
     * 
     * @param userRole 用户角色
     * @return 用户列表
     */
    @Select("SELECT * FROM user WHERE user_role = #{userRole} AND deleted = 0")
    List<User> selectByUserRole(@Param("userRole") String userRole);

    /**
     * 根据学生ID查询用户
     * 
     * @param studentId 学生ID
     * @return 用户信息
     */
    @Select("SELECT * FROM user WHERE student_id = #{studentId} AND deleted = 0")
    User selectByStudentId(@Param("studentId") Integer studentId);

    /**
     * 根据组织者ID查询用户
     * 
     * @param organizerId 组织者ID
     * @return 用户信息
     */
    @Select("SELECT * FROM user WHERE organizer_id = #{organizerId} AND deleted = 0")
    User selectByOrganizerId(@Param("organizerId") Integer organizerId);
}